<div id="supplier-contain" class="ui-widget">
<div><span><b>当前位置:</b></span><?php echo '<b>&nbsp;&nbsp;<a style="color:blue" href="javascript:void(0)" onclick="closeDishPage()">'.$result_supplier_name.'</a> >> '.$result_dish_cate_name.'</b>'?></div>
<table id="category" class="ui-widget ui-widget-content">
	<thead>
		<tr class="ui-widget-header ">
			<th><input type="checkbox" onclick="changeSelectAll(this,'checkSubKey');"></th>
			<th>菜色名称</th>
			<th>价钱</th>
			<th>子类目</th>
			<th>价钱二</th>
			<th>价钱三</th>
			<th>图片</th>
			<th>描述</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
	<?php
	foreach ($result_dish as $item) {
		echo '<tr><td><input type="checkbox" class="checkSubKey" key="'.$item->id.'"/></td>';
		echo '<td>'.$item->displayDishName().'</td>';
		if($item->price == 9999){
			echo '<td>时价</td>';
		}elseif($item->price == 0){
			if(!empty($item->desc)){
				echo '<td>'.$item->desc.'</td>';
			}else{
				echo '<td>暂无参考价格</td>';
			}
		}else{
			echo '<td>'.$item->price.'</td>';
		}
		
		echo '<td>';
		$dish_items = ORM::factory("dishItem")->where("status","<>","I")->and_where("dishid","=",$item->id)->find_all();
		foreach ($dish_items as $ditem){
			echo '<span id="dish-item-'.$ditem->id.'">';
			echo $ditem->displayWithPrice();
			echo '&nbsp;<a style="color:blue" title="修改" href="javascript:void(0)" onclick="editDishItemDialog('.$item->id.','.$ditem->id.')">修改</a>';
			echo '&nbsp;<a style="color:blue" title="删除" href="javascript:void(0)" onclick="deleteDishItem('.$ditem->id.')">删除</a>';
			echo '<br/>';
			echo '</span>';
		}
		echo '</td>';
		if($item->price2 == 9999){
			echo '<td>时价</td>';
		}elseif($item->price2 == 0){
			echo '<td>暂无</td>';
		}else{
			echo '<td>'.$item->price2.'</td>';
		}
		if($item->price3 == 9999){
			echo '<td>时价</td>';
		}elseif($item->price3 == 0){
			echo '<td>暂无</td>';
		}else{
			echo '<td>'.$item->price3.'</td>';
		}
		echo '<td>';
		if(!empty($item->picture)){
			echo '<a target="_blank" href="'.URL::domain().DISH_IMG_PATH.$item->picture.'"><img src="'.URL::domain().DISH_IMG_PATH.$item->picture.'" width="100ps" /></a></td>';
		}
		echo '<td>'.$item->desc.'</td>';
		echo '<td><a style="color:blue" title="修改" href="javascript:void(0)" onclick="editDish('.$item->id.')">修改</a>';
		echo '&nbsp;<a style="color:blue" title="添加子类目" href="javascript:void(0)" onclick="addDishItemDialog('.$item->id.')">添加子类目</a>';
		if (!empty($item->copyfrom)){
			echo '&nbsp;|&nbsp;';
			echo '<a style="color:blue" title="去掉复制标示" href="javascript:void(0)" onclick="removeCopyFlag(\'dish\','.$item->id.')">去掉复制标示</a>';
		}
		echo '</td>';
		echo '</tr>';
	}
	?>
	</tbody>
</table>
</div>
<button id="create-dish">增加菜色</button>
<button id="delete-dish">删除选中菜色</button>
<br/>
<select id="combobox" name="membersupplier">
	<?php 
		$result_suppliers = ORM::factory("supplier")->where("status","<>","I")->find_all();
		$first_supplier_id = null;
		foreach ($result_suppliers as $item){
			if (empty($first_supplier_id)){
				$first_supplier_id = $item->id;
			}
			echo '<option value="'.$item->id.'"';
			echo '>'.$item->displaySupplierName().'</option>';
		}
	?>
</select>
<select id="dishCategorySelect" name="dishCategorySelect">
<?php 
	$result_dish_category = ORM::factory("dishCategory")->where("supplierid","=",$first_supplier_id)->and_where("status","<>","I")->find_all();
	foreach ($result_dish_category as $item){
		echo '<option value="'.$item->id.'"';
		echo '>'.$item->name.'</option>';
	}
?>
	
</select>
<button id="copy-dish-btn">复制选中菜系</button>
<style>
	.ui-button { margin-left: -1px; }
	.ui-button-icon-only .ui-button-text { padding: 0.35em; } 
	.ui-autocomplete-input { margin: 0; padding: 0.48em 0 0.47em 0.45em; width :20%}
</style>
<script type="text/javascript" src="<?php echo URL::base()?>js/self_autocomplete.js"></script>
<script>
$(function() {
	$( "#combobox" ).combobox();
});

function getDishCategoryById(){
	var params = {
		supId:$("#combobox").val()
	}
	ajaxGet(website + "boDishCategory/dishCategoryData/", params, function(result) { 
		$("#dishCategorySelect").html(result);
		mask.close();
	}, "html");
}
</script>